package org.come.until;

import com.tool.PlayerKill.PKSys;
import com.tool.image.ImageMixDeal;
import com.tool.role.RoleData;
import com.tool.tcp.Sprite;
import com.tool.tcp.SpriteFactory;
import com.tool.tcpimg.UIUtils;
import com.tool.time.TimeLimit;
import com.updateNew.MyIsif;
import org.come.Frame.NPCJfram;
import org.come.Frame.TestsmallmapJframe;
import org.come.Frame.WorldTestsmallmapJframe;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.FrameMessageChangeJpanel;
import org.come.Jpanel.GameJpanel;
import org.come.Jpanel.ZhuJpanel;
import org.come.bean.ConfigureBean;
import org.come.bean.LoginResult;
import org.come.bean.Mapmodel;
import org.come.entity.Mount;
import org.come.entity.RegionResult;
import org.come.entity.RoleSummoning;
import org.come.model.*;
import org.come.mouslisten.GoodsMouslisten;
import org.come.npc.Creeps;
import org.come.npc.TP;
import org.come.socket.Agreement;
import org.come.socket.GameClient;
import org.come.socket.SendMessageUntil;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Timer;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;

/*
 * 初始化地图属性和人物位置
 */
public class Util {
    private static final String[] NUMS = new String[]{"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
    private static final String[] UNITS = new String[]{"", "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千"};
    public static long nowtime = 0;
    /**
     * 对话框停留时间绘制次数
     */
    public static int TIME_CHAT2 = 108;
    /**
     * 对话框停留时间
     */
    public static long TIME_CHAT = 2500;
    /**
     * 清除tcp时间
     */
    public static long TIME_TCP = 500;
    /**
     * 障碍物格子
     */
    public static final int CELL_WIDTH = 20;
    /**
     * 移动触发暗雷怪的间隔
     */
    public final static int CREEPS = 320;
    // 是否隐藏称谓
    public static boolean hideTitle = true;
    /**
     * 属于触发暗雷怪地图
     */
    public static boolean CREEPSMAP = false;
    /**
     * 随机数产生
     */
    public static Random random = new Random();
    public static int ditubianma = 0;
    /**
     * 地图运行时间
     */
    public static long maptime = 0;
    /**
     * 地图参数
     */
    public static Mapmodel mapmodel = new Mapmodel();
    /**
     * 北京时间
     */
    private static long BJTime;
    /**
     * 背包锁
     */
    public static boolean canBuyOrno = false;
    private static long dateTime;
    public static int nums = 0;//判断是否在刮刮乐抽奖
    public static String mapName = "";//地图
    public static String xy = "";//坐标
    public static Long startTime = 0L;//进入地图时间
    public static String startTimeName = "";//进入地图时间
    public static boolean ifpf = false;//是否进入泡点地图

    //新增小地图设置
    public static String Smapcs;
    public static String Smapnpc;
    public static String Smapqtnpc;
    //新增小地图设置

    public static boolean dhjl = false;//大话精灵提示语
    public static boolean ZOU = false;//
    public static boolean dj = false;//
    //飞行器
    public static int oldFly_id = 0;//
    public static int oldFlyIndex = 0;//
    public static JList<String> oldFly;//

    public static int moveGrade = 0;//
    public static int zzs = 5;//种族数
    public static List<RegionResult> regionResultList = new ArrayList();
    /**
     * 坐骑技能效果系数
     */
    public static double[] xishu = {0.3, 0.3, 0.7, 0.7, 0, 0, 10000, 10000, 1.2};
    public static double[][] zuoqi = {{4.115226337, 1.141552511}, {14.40329218, 3.99543379}, {4.8, 1.333333333},
            {14.4, 4}, {14.4, 4}, {3.6, 1}, {7.2, 2}, {4.8, 1.333333333}, {7.2, 2}, {4.8, 1.333333333},
            {7.2, 2}, {4.8, 1.333333333}, {7.2, 2}, {7.2, 2}, {4.8, 1.333333333}, {7.2, 2}, {14.4, 4},
            {4.8, 1.333333333}, {7.2, 2}, {4.8, 1.333333333}, {3.6, 1}, {14.4, 4}, {7.2, 2}};
    // 金币上限
    public static BigDecimal GoldUP = new BigDecimal("999999999999");
    public static Vector<String> vector = new Vector<String>();
    private static Object Ex4_1;

    static {
        BJTime = new Long("1587606505273");
        vector.add("成员名称");
        vector.add("职务");
        vector.add("种族");
        vector.add("等级");
        vector.add("贡献");
        vector.add("成就");
        vector.add("上线时间");
    }

    public static Vector<String> vector2 = new Vector<String>();

    static {
        vector2.add("名字");
        vector2.add("等级");
        vector2.add("种族");
        vector2.add("性别");
    }

    public static Vector<String> vector3 = new Vector<String>();

    static {
        vector3.add("");
        vector3.add("");
        vector3.add("");
        vector3.add("");
        vector3.add("");
    }
    public static Vector<String> vector4 = new Vector<String>();

    static {
        vector4.add("");
        vector4.add("");
        vector4.add("");
        vector4.add("");
        vector4.add("");
    }
    // 判断非法字符
    public static boolean isIllegal(String name) {
        boolean bool = true;
        String ss = "管理|GM|gm|Gm|gM|卖|物集|菜|新开|群|号|币|艹|贱";
        String[] v = ss.split("\\|");
        for (int i = 0; i < v.length; i++) {
            if (name.contains(v[i])) {
                bool = false;
                break;
            }
        }
        return bool;
    }
    public static String convert(String html) {
        if (html == null || !html.equals("")) {
            return "";
        }
        if(!html.contains("<p")) {
            return html;
        }
        Document doc = Jsoup.parse(html);

        StringBuilder textBuilder = new StringBuilder();
        // 获取所有段落元素
        Elements paragraphs = doc.select("p");
        for (Element paragraph : paragraphs) {
            // 添加段落文本
            textBuilder.append("#Y"+paragraph.text());
            // 添加换行
            textBuilder.append(System.lineSeparator());
        }

        return textBuilder.toString();
    }
    // 初始化时间
    public static void uptime(String uptime) {
        try {
            BJTime = Long.parseLong(uptime) + 3000;
        } catch (Exception e) {
            // TODO: handle exception
            BJTime = WebTimeUntil.getNetworkTime();

        }
    }

    /**
     * 读取用户常用角色信息
     */
    public static String readUserInfo() {
        try {
            GameClient.Mac = GameClient.getLocalMac();
        } catch (Exception e) {
            e.printStackTrace();
        }
        String value = readTxt("resource/other/RecordUserInfo.txt");
        if (value == null || "".equals(value)) {
            return "";
        }
        String value2 = null;
        try {
            value2 = NewAESUtil.AESJDKDncode_utf8(value);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (value2 == null) {
            return "";
        }
        value2 = value2.substring(13);
        if (value2.startsWith(GameClient.Mac)) {
            return value2.substring(17);
        }
        return "";
    }

    public static void writeUserInfo(String text) {
        try {
            String filein = GameClient.Mac + text;
            try (OutputStreamWriter write = new OutputStreamWriter(new FileOutputStream(new File(
                    "resource/other/RecordUserInfo.txt")), StandardCharsets.UTF_8);
                 BufferedWriter writer = new BufferedWriter(write)) {
                writer.write(NewAESUtil.AESJDKEncode(filein));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static RegionResult getRegionResultByName(String name) {
        for (int i = 0; i < regionResultList.size(); i++) {
            if (regionResultList.get(i).getRA_NAME().equals(name)) {
                return regionResultList.get(i);
            }
        }
        return null;
    }

    public static RegionResult getRegionResult(BigDecimal RA_ID) {
        for (int i = 0; i < regionResultList.size(); i++) {
            if (regionResultList.get(i).getRA_ID().compareTo(RA_ID) == 0) {
                return regionResultList.get(i);
            }
        }
        return null;
    }

    /**
     * 泡点相关
     */
    private static Long tm = 0L;//获经验间隔
    private static Long hf = 0L;//花费
    private static Long jy = 0L;//获得经验
    private static Long jz = 0L;//介质
    public static Long hdzjy = 0L;//获得总经验
    public static Long xfzje = 0L;//消费总金币
    public static Long xfzxy = 0L;//消费总仙玉
    public static String pdtype = "";//1激情泡点、2金币泡点、3仙玉泡点
    public static Long victory = 1L;//胜利场次  最高5
    public static boolean qbg = true;//
    public static boolean ifjr = false;//

    public synchronized static void loadMap(int mapid, int x, int y) {
        if (mapid != 1207) {
            if (ditubianma == mapid) {
                if (GameJpanel.isAlpha) {
                    GameJpanel.alpha = 0.35f;
                } else {
                    GameJpanel.isAlpha = true;
                }
                mapmodel.force(x, y);
                return;
            }
        }
        if (mapid == 3333) {
            FormsManagement.showForm(9);
        } else if (ditubianma == 3333) {
            FormsManagement.HideForm(9);
        }
        ditubianma = mapid;
        maptime = 0;
        Gamemap gamemap = UserMessUntil.getAllmapbean().getAllMap().get(ditubianma + "");
        mapmodel.setGamemap(gamemap);
        // 加载传送门
        List<Door> doors = new ArrayList<>();
        if (gamemap.getMapway() != null) {
            List<String> strings = SplitStringTool.splitString(gamemap.getMapway());
            for (int i = 0; i < strings.size(); i++) {
                doors.add(UserMessUntil.getDoor(strings.get(i)));
            }
        }
        mapmodel.setDoors(doors);
        ImageMixDeal.NpcLoad(gamemap.getMapnpc());
        DarkCreeps(gamemap.getMonster());
        GregorianCalendar calendar = new GregorianCalendar();
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        //if ((ditubianma == 1193 || ditubianma == 1207) && (hour >= 19 || hour <= 7))
        if ((ditubianma == 1207) && (hour >= 19 || hour <= 7)) {
            mapmodel.getjMap().loadMap(new File("resource/map/" + ditubianma + "1.map"), doors);
        } else {
            mapmodel.getjMap().loadMap(new File("resource/map/" + ditubianma + ".map"), doors);
        }
        // 重置大小
        mapmodel.Mapsize();
        mapmodel.force(x, y);
        //判断泡点地图
        if ("3344".equals(Util.mapmodel.getGamemap().getMapid()) || "3342".equals(Util.mapmodel.getGamemap().getMapid()) || ("1207".equals(Util.mapmodel.getGamemap().getMapid()) && "1".equals(pdtype))) {
            ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
            Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
            Configure configure = item.get(new BigDecimal(1));
            String[] expAdd = configure.getExpAdd().split("\\|");


            tm = Long.parseLong(expAdd[0]);//获经验间隔
            hf = Long.parseLong(expAdd[1]);//花费
            jy = Long.parseLong(expAdd[2]);//获得经验
            if (isjb(hf) || "1".equals(pdtype)) {
                FormsManagement.HideForm(3003);

                String text = "";
                if (!"1".equals(pdtype)) {
                    text = "#R注意：#Y您已进入泡点地图，请注意消费金额！！！";
                } else {
                    text = "#R注意：#Y您已进入泡点地图！！！";
                }
                qbg = true;
                GameJpanel.getGameJpanel().addPrompt("#Y" + text);
//                FrameMessageChangeJpanel.addtext(6, text, null, null);
                hdzjy = 0L;//获得总经验
                xfzje = 0L;//消费总金额
                DateFormat df = new SimpleDateFormat("HH:mm:ss");
                startTimeName = df.format(new Date());
                startTime = new Date().getTime();
                ifpf = true;
            } else {
                pdtype = "";
                ZhuFrame.getZhuJpanel().addPrompt2("#R注意：#Y金钱不足，无法进入泡点地图！努力赚钱，下次再来！");
                iWantToFly("1207,长安城,4960,3820");
            }
        } else {
            hdzjy = 0L;//获得总经验
            xfzje = 0L;//消费总金额
            xfzxy = 0L;//消费总金额
            ifpf = false;
            pdtype = "";
        }

        try {
            Image image;
//            if ((ditubianma == 1193 || ditubianma == 1207) && (hour >= 19 || hour <= 7)) {
//                image = new ImageIcon("resource/smap/s" + ditubianma + "1.png").getImage();
//            } else {
            if ("水墨UI".equals(MyIsif.getStyle())) {
                image = new ImageIcon("inkImg/number/npk/s/s" + ditubianma + ".png").getImage();
            } else {
                image = new ImageIcon("inkImg/number/npk/s/h" + ditubianma + ".png").getImage();
            }

//            }
            if (image.getWidth(null) <= 0) {
                TestsmallmapJframe.getTestsmallmapJframe().setBounds(70, 80, 5, 1);
            } else {
                TestsmallmapJframe.getTestsmallmapJframe().setBounds(70, 80, image.getWidth(null) + 5,
                        image.getHeight(null) + 1);
            }
            mapmodel.MiniMap(image);
            WorldTestsmallmapJframe.getWorldTestsmallmapJpanel();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // 进入游戏判断是否播放背景音乐
        if (Music.kz1) {


            if (Music.MusicNew != null) {
                if ("1".equals(Music.MusicNew)) {
                    try {
                        Music.addbeijing(gamemap.getMusic() + "o.mp3");
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        // e.printStackTrace();
                    }
                } else if ("2".equals(Music.MusicNew)) {
                    try {
                        Music.addbeijing(gamemap.getMusic() + ".mp3");
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        // e.printStackTrace();
                    }
                }
            }

        }
    }

    //TODO 左上角长安地图字符文本显示
    public static void dogame(LoginResult loginResult) {
        int x = loginResult.getX().intValue();
        int y = loginResult.getY().intValue();
        int map_id = loginResult.getMapid().intValue();
        boolean isCM = ditubianma != map_id;
        if (isCM) {
            CREEPSMAP = false;
        }
        loadMap(map_id, x, y);
        Util.mapName = mapmodel.getGamemap().getMapname();
        ZhuJpanel.getxAndY().setText(Util.mapName + "   [ " + loginResult.getX() / 20 + "," + loginResult.getY() / 20 + " ]");
//        ZhuJpanel.getMapName().setText(mapmodel.getGamemap().getMapname());
        if (isCM) {
            if (PKSys.getPkSys().getPk1() > 4) {
                if (PKSys.getPkSys().getPk2() == 0) {
                    String[] v = ImageMixDeal.userimg.getTeams();
                    if (v != null && !CREEPSMAP && random.nextInt(100) < 30) {
                        // 判断是否进城遇到天兵抓人
                        Creeps.getfight(15);
                    } else {
                        ZhuFrame.getZhuJpanel().addPrompt2("你当前有" + PKSys.getPkSys().getPk1() + "点PK标志,进城有惊喜");
                    }
                }
            }

        }
        /*=========================左上角显示时间=========================*/


        Timer timer = new Timer();
        long date = 0;
        timer.scheduleAtFixedRate(new TimerTask() {
            public void run() { //从这里开始，
                Date date = new Date();
//                DateFormat df = new SimpleDateFormat("HH:mm:ss");
//                String format = df.format(date);
                Calendar cal = Calendar.getInstance();
                String format = Util.getHour(date.getHours());
                format = format.replace("", " ").trim();
                ZhuJpanel.getTimemiao().setText(format); //JLable调用settext方法，输入时间字符串。
            } //到这里结束，是TimerTask的匿名内部类，重写run方法，
        }, date, 2000); //当前时间，延迟时间1000毫秒。
        /*=========================左上角显示时间=========================*/


    }

    public static void changeJLabelTextColor(JLabel field, BigDecimal money) {
        if (money.compareTo(b1) < 0) {
            field.setForeground(Color.white);
        } else if (money.compareTo(b2) < 0) {
            field.setForeground(new Color(36, 219, 118));
        } else if (money.compareTo(b3) < 0) {
            field.setForeground(new Color(253, 68, 221));
        } else if (money.compareTo(b4) < 0) {
            field.setForeground(new Color(251, 217, 50));
        } else if (money.compareTo(b5) < 0) {
            field.setForeground(new Color(0, 239, 239));
        } else if (money.compareTo(b6) < 0) {
            field.setForeground(Color.GREEN);
        } else {
            field.setForeground(Color.RED);
        }
    }


    //点卡记录
    public void dtime() {
        LoginResult loginResult = RoleData.getRoleData().getLoginResult();
        loginResult.setGameTimeRemaining(loginResult.getGameTimeRemaining() - 1);
    }


    /**
     * 判断是否遇上暗雷怪
     */
    public static void GotoCreeps() {
        if (random.nextInt(CREEPS) == 0) {
            if (good()) {
                Creeps.yeguai();
            }
        }

    }

    /**
     * 判断是否有躲避暗雷怪道具 true 没有
     */
    public static boolean good() {
        if (ImageMixDeal.userimg.getRoleShow().getFighting() != 0) {
            return false;
        }
        //飞行器相关
        boolean k = true;
        if (ImageMixDeal.userimg.getRoleShow().getFly_id() != 0) {
            k = false;
        }
        if (!k) {
            return false;
        } else if (TimeLimit.getLimits().getLimit("摄妖香") != null) {
            if (AnalysisString.lvlint(ImageMixDeal.userimg.getRoleShow().getGrade()) - 10 > Integer.parseInt(mapmodel.getGamemap().getMaplvl())) {
                return false;
            }
        }
        return true;
    }

    /**
     * 判断该地图是否有暗雷怪
     */
    public static void DarkCreeps(String ids) {
        if (ids == null || "".equals(ids)) {
            CREEPSMAP = false;
        } else {
            CREEPSMAP = true;
        }
    }

    /**
     * 根据id换取性别0女 1男
     */
    public static int getSex(BigDecimal se) {
        int id = se.intValue() % 100;
        return (id == 1 || id == 2 || id == 3 || id == 7 || id == 9 || id == 11) ? 1 : 0;
    }

    /**
     * 根据id换取性别0女 1男
     */
    public static String getSexSting(BigDecimal se) {
        int id = se.intValue() % 100;
        return (id == 1 || id == 2 || id == 3 || id == 7 || id == 9 || id == 11) ? "男" : "女";
    }

    /**
     * 种族
     */
    public static int getRace(BigDecimal se) {
        if (se == null) {
            return 0;
        }
        int id = se.intValue();
        if (id >= 20001 && id <= 20012) {
            return 10001;
        } else if (id >= 21001 && id <= 21012) {
            return 10002;
        } else if (id >= 22001 && id <= 22012) {
            return 10003;
        } else if (id >= 23001 && id <= 23012) {
            return 10004;
        } else {
            return 10005;
        }
    }

    /**
     * 种族
     */
    public static String getRaceSting(BigDecimal se) {
        if (se == null) {
            return "";
        }
        int id = se.intValue();
        if (id >= 20001 && id <= 20012) {
            return "人";
        } else if (id >= 21001 && id <= 21012) {
            return "魔";
        } else if (id >= 22001 && id <= 22012) {
            return "仙";
        } else if (id >= 23001 && id <= 23012) {
            return "鬼";
        } else {
            return "龙";
        }
    }

    /**
     * 种族和角色名称
     */
    public static String getRaceStingmc(BigDecimal se) {
        if (se == null) {
            return "";
        }
        int id = se.intValue();
        if (id == 20001) {
            return "逍遥生·人族";
        } else if (id == 20002) {
            return "剑侠客·人族";
        } else if (id == 20003) {
            return "猛壮士·人族";
        } else if (id == 20004) {
            return "飞燕女·人族";
        } else if (id == 20005) {
            return "英女侠·人族";
        } else if (id == 20006) {
            return "俏千金·人族";
        } else if (id == 20007) {
            return "飞剑侠·人族";
        } else if (id == 20008) {
            return "燕山雪·人族";
        } else if (id == 20009) {
            return "纯阳子·人族";
        } else if (id == 20010) {
            return "红拂女·人族";
        } else if (id == 20011) {
            return "神秀生·人族";
        } else if (id == 20012) {
            return "玲珑女·人族";
        } else if (id == 21001) {
            return "虎头怪·魔族";
        } else if (id == 21002) {
            return "夺命妖·魔族";
        } else if (id == 21003) {
            return "巨魔王·魔族";
        } else if (id == 21004) {
            return "小蛮妖·魔族";
        } else if (id == 21005) {
            return "骨精灵·魔族";
        } else if (id == 21006) {
            return "狐美人·魔族";
        } else if (id == 21007) {
            return "逆天魔·魔族";
        } else if (id == 21008) {
            return "媚灵狐·魔族";
        } else if (id == 21009) {
            return "混天魔·魔族";
        } else if (id == 21010) {
            return "九尾狐·魔族";
        } else if (id == 21011) {
            return "绝影魔·魔族";
        } else if (id == 21012) {
            return "霜月灵·魔族";
        } else if (id == 22001) {
            return "神天兵·仙族";
        } else if (id == 22002) {
            return "智圣仙·仙族";
        } else if (id == 22003) {
            return "龙战将·仙族";
        } else if (id == 22004) {
            return "精灵仙·仙族";
        } else if (id == 22005) {
            return "舞天姬·仙族";
        } else if (id == 22006) {
            return "玄剑娥·仙族";
        } else if (id == 22007) {
            return "武尊神·仙族";
        } else if (id == 22008) {
            return "玄天姬·仙族";
        } else if (id == 22009) {
            return "紫薇神·仙族";
        } else if (id == 22010) {
            return "霓裳仙·仙族";
        } else if (id == 22011) {
            return "青阳使·仙族";
        } else if (id == 22012) {
            return "云中君·仙族";
        } else if (id == 23001) {
            return "祭剑魂·鬼族";
        } else if (id == 23002) {
            return "猎魂引·鬼族";
        } else if (id == 23003) {
            return "无崖子·鬼族";
        } else if (id == 23004) {
            return "墨衣行·鬼族";
        } else if (id == 23005) {
            return "夜溪灵·鬼族";
        } else if (id == 23006) {
            return "幽梦影·鬼族";
        } else if (id == 23007) {
            return "南冠客·鬼族";
        } else if (id == 23008) {
            return "镜花影·鬼族";
        } else if (id == 24001) {
            return "沧浪君·龙族";
        } else if (id == 24002) {
            return "龙渊客·龙族";
        } else if (id == 24003) {
            return "忘忧子·龙族";
        } else if (id == 24004) {
            return "骊珠儿·龙族";
        } else if (id == 24005) {
            return "木兰行·龙族";
        } else if (id == 24006) {
            return "莫解语·龙族";
        } else if (id == 24007) {
            return "游无极·龙族";
        } else if (id == 24008) {
            return "临九渊·龙族";
        } else {
            return "缺少";
        }
    }

    /**
     * 判断字符串是否含有特殊符号
     **/
    public static boolean special(String ChangeName) {
        String[] a = {"!", "|", "*", "&", "@", "#", "$", "%", "^", "/", " "};
        for (int i = 0; i < a.length; i++) {
            if (ChangeName.indexOf(a[i]) != -1) {
                return false;
            }
        }
        return true;
    }

    public final static BigDecimal b1 = new BigDecimal(10000);
    public final static BigDecimal b2 = new BigDecimal(100000);
    public final static BigDecimal b3 = new BigDecimal(1000000);
    public final static BigDecimal b4 = new BigDecimal(10000000);
    public final static BigDecimal b5 = new BigDecimal(100000000);
    public final static BigDecimal b6 = new BigDecimal(1000000000);

    /**
     * 判断金币颜色变化
     */
    public static void drawMoney(Graphics g, int x, int y) {
        BigDecimal money = RoleData.getRoleData().getLoginResult().getGold();
        drawPrice(g, money, x, y);
    }

    public static void drawMoneyJF(Graphics g, int x, int y) {
        BigDecimal money = new BigDecimal(RoleData.getRoleData().getLoginResult().getMoney());
        drawPrice(g, money, x, y);
    }

    static Sprite MallX = SpriteFactory.VloadSprite("inkImg/hongmu/1/4389-D1D89FFE.tcp", null);

    /**
     * 判断xianyu颜色变化
     */
    public static void drawMoneyS(Graphics g, int x, int y) {
        g.drawString(RoleData.getRoleData().getLoginResult().getCodecard().toString(), x, y);
        //MallX.updateToTime(ImageMixDeal.userimg.getTime(), 0);
        // MallX.draw(g,ScrenceUntil.Screen_x- 150 ,ScrenceUntil.Screen_y - 700);
    }

    /**
     * 判断单价/总价颜色变化
     */
    public static void drawPrice(Graphics g, BigDecimal money, int x, int y) {
        if (money.compareTo(b1) < 0) {
            g.setColor(Color.white);
        } else if (money.compareTo(b2) < 0) {
            g.setColor(new Color(36, 219, 118));
        } else if (money.compareTo(b3) < 0) {
            g.setColor(new Color(253, 68, 221));
        } else if (money.compareTo(b4) < 0) {
            g.setColor(new Color(251, 217, 50));
        } else if (money.compareTo(b5) < 0) {
            g.setColor(new Color(0, 239, 239));
        } else if (money.compareTo(b6) < 0) {
            g.setColor(Color.GREEN);
        } else {
            g.setColor(Color.RED);
        }
        g.setFont(UIUtils.TEXT_FONT1);
        if (money.compareTo(new BigDecimal(1000)) >= 0) {
            String str = money.toString();
            StringBuffer gold = new StringBuffer(str);
            int index;
            for (index = gold.length() - 3; index > 0; index -= 3) {
                gold.insert(index, ',');
            }
            g.drawString(gold.toString(), x, y);
        } else {
            g.drawString(money.toString(), x, y);
        }
    }

    /**
     * 根据金币数量改变输入框字体颜色
     */
    public static void changeTextColor(JTextField field, BigDecimal money) {
        if (money.compareTo(b1) < 0) {
            field.setForeground(Color.white);
        } else if (money.compareTo(b2) < 0) {
            field.setForeground(new Color(36, 219, 118));
        } else if (money.compareTo(b3) < 0) {
            field.setForeground(new Color(253, 68, 221));
        } else if (money.compareTo(b4) < 0) {
            field.setForeground(new Color(251, 217, 50));
        } else if (money.compareTo(b5) < 0) {
            field.setForeground(new Color(0, 239, 239));
        } else if (money.compareTo(b6) < 0) {
            field.setForeground(Color.GREEN);
        } else {
            field.setForeground(Color.RED);
        }
    }

    /**
     * 判断一个子符串中都是数字
     */
    public static boolean isNumeric(String str) {
        Pattern pattern = Pattern.compile("[0-9]*");
        return pattern.matcher(str).matches();
    }

    /**
     * 读取文本文件
     */
    public static List<String> readGG(String path) {
        List<String> gg = new ArrayList<>();
        String read;
        try (FileInputStream fis = new FileInputStream(new File(path));
             InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
             BufferedReader br = new BufferedReader(isr)) {
            while ((read = br.readLine()) != null) {
                gg.add(read);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return gg;
    }

    /**
     * 读取记录用户密码文件
     */
    public static String readUserPwd() {
        String value = readTxt("resource/other/RecordUser.txt");
        if (value == null || "".equals(value)) {
            return "";
        }
        String value2 = NewAESUtil.AESJDKDncode(value);
        if (value2 == null) {
            if (value.indexOf("=") != -1) {
                writeUserPwd(value);
                return value;
            }
            return "";
        }
        value2 = value2.substring(13);
        if (GameClient.Mac == null) {
            try {
                GameClient.getServerIpAndPort();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        if (value2.startsWith(GameClient.Mac)) {
            return value2.substring(17);
        }
        return "";
    }

    /**
     * 添加记录用户密码文件
     */
    public static void writeUserPwd(String text) {
        try {
            //system.out.println(GameClient.Mac);
            String filein = GameClient.Mac + text;
            try (OutputStreamWriter write = new OutputStreamWriter(new FileOutputStream(new File(
                    "resource/other/RecordUser.txt")), "UTF-8");
                 BufferedWriter writer = new BufferedWriter(write)) {
                writer.write(NewAESUtil.AESJDKEncode(filein));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 读取文本文件
     */
    public static String readTxt(String path) {
        String readStr = "";
        try {
            File file = new File(path);
            if (!file.exists()) {
                return null;
            }
            try (FileInputStream fis = new FileInputStream(new File(path));
                 InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
                 BufferedReader br = new BufferedReader(isr)) {
                String read;
                while ((read = br.readLine()) != null) {
                    readStr = readStr + read;
                }
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return readStr;
    }

    /**
     * 将坐骑几率改成百分比形式
     */
    public static String changeToPercentage(String mountskillmsg) {
        String newmsg = "";
        String[] strings = mountskillmsg.split("\\=");

        if ("抗三尸虫".equals(strings[0])) {
            newmsg = strings[0] + "+" + Integer.parseInt(strings[1]);
        } else {
            newmsg = strings[0] + "+" + (int) (Float.parseFloat(strings[1]) * 100) + "%";
        }
        return newmsg;
    }

    /**
     * 计算坐骑技能四维加成的方法
     */
    public static String calculateAdditionBase(Mount mount, String skillname) {
        if ("夺命追魂".equals(skillname)) {
            return returnsCalculation("SP", mount, "夺命追魂");
        } else if ("天雷怒火".equals(skillname)) {
            return returnsCalculation("MP", mount, "天雷怒火");
        } else if ("金身不坏".equals(skillname)) {
            return returnsCalculation("HP", mount, "金身不坏");
        } else if ("破釜沉舟".equals(skillname)) {
            return returnsCalculation("AP", mount, "破釜沉舟");
        } else if ("兴风作浪".equals(skillname)) {
            return returnsCalculation("MP", mount, "兴风作浪");
        } else if ("天神护体".equals(skillname)) {
            return returnsCalculation("SP", mount, "天神护体");
        } else if ("后发制人".equals(skillname)) {
            return returnsCalculation("HP", mount, "后发制人");
        } else if ("万劫不复".equals(skillname)) {
            return returnsCalculation("MP", mount, "万劫不复");
        } else if ("心如止水".equals(skillname)) {
            return returnsCalculation("HP", mount, "心如止水");
        }else if (skillname.equals("游刃有余")) {
            return returnsCalculation("SP", mount, "游刃有余");
        } else if (skillname.equals("反客为主")) {
            return returnsCalculation("AP", mount, "反客为主");
        } else if (skillname.equals("反治其身")) {
            return returnsCalculation("HP", mount, "反治其身");
        } else if (skillname.equals("视险如夷")) {
            return returnsCalculation("HP", mount, "视险如夷");
        } else if (skillname.equals("山外青山")) {
            return returnsCalculation("SP", mount, "山外青山");
        } else if (skillname.equals("得心应手")) {
            return returnsCalculation("MP", mount, "得心应手");
        }
        return null;
    }

    /**
     * 计算坐骑技能加成的方法
     */
    public static String calculateAddition(Mount mount, String skillname) {
        String value = "";
        // 判断是什么种族坐骑
        // 判断是几阶的技能
        if ("夺命追魂".equals(skillname)) {
            String s1 = returnsCalculation("SP", mount, "夺命追魂");
            String s2 = returnsCalculation("连击率", mount, "夺命追魂");
            String s3 = returnsCalculation("致命", mount, "夺命追魂");
            String s4 = returnsCalculation("命中", mount, "夺命追魂");
            value = s1 + "|" + s2 + "|" + s3 + "|" + s4;
        } else if ("天雷怒火".equals(skillname)) {
            String s1 = returnsCalculation("MP", mount, "天雷怒火");
            String s2 = returnsCalculation("火法伤害", mount, "天雷怒火");
            String s3 = returnsCalculation("雷法伤害", mount, "天雷怒火");
            String s4 = returnsCalculation("抗火法", mount, "天雷怒火");
            String s5 = returnsCalculation("抗雷法", mount, "天雷怒火");
            String s6 = returnsCalculation("抗鬼火", mount, "天雷怒火");
            value = s1 + "|" + s2 + "|" + s3 + "|" + s4 + "|" + s5 + "|" + s6;
        } else if ("金身不坏".equals(skillname)) {
            String s1 = returnsCalculation("HP", mount, "金身不坏");
            String s2 = returnsCalculation("抗物理", mount, "金身不坏");
            String s3 = returnsCalculation("抗震慑", mount, "金身不坏");
            String s4 = returnsCalculation("抗中毒", mount, "金身不坏");
            String s5 = returnsCalculation("抗三尸虫", mount, "金身不坏");
            value = s1 + "|" + s2 + "|" + s3 + "|" + s4 + "|" + s5;
        } else if ("破釜沉舟".equals(skillname)) {
            String s1 = returnsCalculation("AP", mount, "破釜沉舟");
            String s2 = returnsCalculation("狂暴", mount, "破釜沉舟");
            String s3 = returnsCalculation("忽视防御几率", mount, "破釜沉舟");
            String s4 = returnsCalculation("忽视防御程度", mount, "破釜沉舟");
            value = s1 + "|" + s2 + "|" + s3 + "|" + s4;
        } else if ("兴风作浪".equals(skillname)) {
            String s1 = returnsCalculation("MP", mount, "兴风作浪");
            String s2 = returnsCalculation("风法伤害", mount, "兴风作浪");
            String s3 = returnsCalculation("水法伤害", mount, "兴风作浪");
            String s4 = returnsCalculation("抗风法", mount, "兴风作浪");
            String s5 = returnsCalculation("抗水法", mount, "兴风作浪");
            String s6 = returnsCalculation("抗鬼火", mount, "兴风作浪");
            value = s1 + "|" + s2 + "|" + s3 + "|" + s4 + "|" + s5 + "|" + s6;
        } else if ("天神护体".equals(skillname)) {
            String s1 = returnsCalculation("SP", mount, "天神护体");
            String s2 = returnsCalculation("抗风法", mount, "天神护体");
            String s3 = returnsCalculation("抗火法", mount, "天神护体");
            String s4 = returnsCalculation("抗水法", mount, "天神护体");
            String s5 = returnsCalculation("抗雷法", mount, "天神护体");
            String s6 = returnsCalculation("抗鬼火", mount, "天神护体");
            value = s1 + "|" + s2 + "|" + s3 + "|" + s4 + "|" + s5 + "|" + s6;
        } else if ("后发制人".equals(skillname)) {
            String s1 = returnsCalculation("HP", mount, "后发制人");
            String s2 = returnsCalculation("狂暴", mount, "后发制人");
            value = s1 + "|" + s2;
        } else if ("万劫不复".equals(skillname)) {
            String s1 = returnsCalculation("MP", mount, "万劫不复");
            String s2 = returnsCalculation("加强风", mount, "万劫不复");
            String s3 = returnsCalculation("加强火", mount, "万劫不复");
            String s4 = returnsCalculation("加强水", mount, "万劫不复");
            String s5 = returnsCalculation("加强雷", mount, "万劫不复");
            value = s1 + "|" + s2 + "|" + s3 + "|" + s4 + "|" + s5;
        } else if ("心如止水".equals(skillname)) {
            String s1 = returnsCalculation("HP", mount, "心如止水");
            String s2 = returnsCalculation("抗昏睡", mount, "心如止水");
            String s3 = returnsCalculation("抗封印", mount, "心如止水");
            String s4 = returnsCalculation("抗中毒", mount, "心如止水");
            String s5 = returnsCalculation("抗混乱", mount, "心如止水");
            String s6 = returnsCalculation("抗遗忘", mount, "心如止水");
            value = s1 + "|" + s2 + "|" + s3 + "|" + s4 + "|" + s5 + "|" + s6;
        } else if (skillname.equals("游刃有余")) {
            String s1 = returnsCalculation("SP", mount, "游刃有余");
            String s2 = returnsCalculation("法术躲闪", mount, "游刃有余");
            String s3 = returnsCalculation("抗灵宝伤害", mount, "游刃有余");
            value = s1 + "|" + s2 + "|" + s3;
        } else if (skillname.equals("反客为主")) {
            String s1 = returnsCalculation("AP", mount, "反客为主");
            String s2 = returnsCalculation("反击率", mount, "反客为主");
//            String s5 = returnsCalculation("反击次数", mount, "反客为主");
            String s3 = returnsCalculation("忽视防御几率", mount, "反客为主");
            String s4 = returnsCalculation("忽视防御程度", mount, "反客为主");
            value = s1 + "|" + s2 + "|" + s3 + "|" + s4;
        } else if (skillname.equals("反治其身")) {
            String s1 = returnsCalculation("HP", mount, "反治其身");
            String s2 = returnsCalculation("躲闪率", mount, "反治其身");
            String s3 = returnsCalculation("反震率", mount, "反治其身");
            String s4 = returnsCalculation("反震程度", mount, "反治其身");
            value = s1 + "|" + s2 + "|" + s3 + "|" + s4;
        } else if (skillname.equals("视险如夷")) {
            String s1 = returnsCalculation("HP", mount, "视险如夷");
            String s2 = returnsCalculation("抵御强克效果", mount, "视险如夷");
            value = s1 + "|" + s2;
        } else if (skillname.equals("山外青山")) {
            String s1 = returnsCalculation("SP", mount, "山外青山");
            String s2 = returnsCalculation("增加强克效果", mount, "山外青山");
            value = s1 + "|" + s2;
        } else if (skillname.equals("得心应手")) {
            String s1 = returnsCalculation("MP", mount, "得心应手");
            String s2 = returnsCalculation("忽视抗风", mount, "得心应手");
            String s3 = returnsCalculation("忽视抗火", mount, "得心应手");
            String s4 = returnsCalculation("忽视抗水", mount, "得心应手");
            String s5 = returnsCalculation("忽视抗雷", mount, "得心应手");
            String s6 = returnsCalculation("忽视鬼火", mount, "得心应手");
            String s7 = returnsCalculation("风法狂暴", mount, "得心应手");
            String s8 = returnsCalculation("火法狂暴", mount, "得心应手");
            String s9 = returnsCalculation("水法狂暴", mount, "得心应手");
            String s10 = returnsCalculation("雷法狂暴", mount, "得心应手");
            String s11 = returnsCalculation("鬼火狂暴", mount, "得心应手");
            value = s1 + "|" + s2+ "|" + s3+ "|" + s4+ "|" + s5+ "|" + s6+ "|" + s7+ "|" + s8+ "|" + s9+ "|" + s10+ "|" + s11;
        }
        return value;
    }

    /**
     * 计算技能效果的方法
     */
    public static String returnsCalculation(String mes, Mount mount, String skillname) {
        double zjxz = 1;
        if (mount.getMountid() == 2 || mount.getMountid() == 4) {
            zjxz = 1.2;
        }
        int grade = mount.getMountlvl();// 等级
        if (grade > 100) {
            grade -= 100;
        }
        // 最新的坐骑属性
        int lingxing = (int) Math.floor(mount.getSpri() + (float) grade / 10 * mount.getSpri() / 2);
        int liliang = (int) Math.floor(mount.getPower() + (float) grade / 10 * mount.getPower() / 2);
        int genggu = (int) Math.floor(mount.getBone() + (float) grade / 10 * mount.getBone() / 2);
        int shulian = mount.getProficiency();// 熟练度
        // 计算出来的技能效果值
        double jnxgz = 0;
        if ("HP".equals(mes)) {
            if ("金身不坏".equals(skillname)) {
                jnxgz = (genggu * xishu[2] + lingxing * xishu[4] + liliang * xishu[1]) * zjxz / zuoqi[4][0] + shulian  / 10000 / zuoqi[4][1];
            } else if ("后发制人".equals(skillname)) {
                jnxgz = (genggu * xishu[0] + lingxing * xishu[4] + liliang * xishu[3]) * zjxz / zuoqi[16][0] + shulian  / xishu[7] / zuoqi[16][1];
            } else if ("心如止水".equals(skillname)) {
                jnxgz = (genggu * xishu[2] + lingxing * xishu[1] + liliang * xishu[5]) * zjxz / zuoqi[1][0] + shulian  / xishu[6] / zuoqi[1][1];
            } else if (skillname.equals("反治其身")) {
                jnxgz = (genggu * xishu[2] + lingxing * xishu[1] + liliang * xishu[5]) * zjxz / zuoqi[1][0] + shulian  / xishu[6] / zuoqi[1][1];
            } else if (skillname.equals("视险如夷")) {
                jnxgz = (genggu * xishu[2] + lingxing * xishu[1] + liliang * xishu[5]) * zjxz / zuoqi[1][0] + shulian  / xishu[6] / zuoqi[1][1];
            }
        } else if ("MP".equals(mes)) {
            if ("天雷怒火".equals(skillname)) {
                jnxgz = (genggu * xishu[4] + lingxing * xishu[3] + liliang * xishu[0]) * zjxz / zuoqi[13][0] + shulian / xishu[6] / zuoqi[13][1];
            } else if ("兴风作浪".equals(skillname)) {
                jnxgz = (genggu * xishu[1] + lingxing * xishu[2] + liliang * xishu[5]) * zjxz / zuoqi[10][0] + shulian  / xishu[6] / zuoqi[10][1];
            } else if ("万劫不复".equals(skillname)) {
                jnxgz = (genggu * xishu[5] + lingxing * 1 + liliang * xishu[4]) * zjxz / zuoqi[8][0] + shulian  / xishu[6] / zuoqi[8][1];
            }else if (skillname.equals("得心应手")) {
                jnxgz = (genggu * xishu[5] + lingxing * 1 + liliang * xishu[4]) * zjxz / zuoqi[8][0] + shulian/ xishu[6] / zuoqi[8][1];
            }
        } else if ("AP".equals(mes)) {
            jnxgz = (genggu * xishu[5] + lingxing * xishu[4] + liliang * 1) * zjxz / zuoqi[18][0] + shulian / xishu[7] / zuoqi[18][1];
            if (skillname.equals("反客为主")) {
                jnxgz = (genggu * xishu[5] + lingxing * xishu[4] + liliang * xishu[1]) * zjxz / zuoqi[18][0] + shulian/ xishu[7] / zuoqi[18][1];
            }
        } else if ("SP".equals(mes)) {
            if ("夺命追魂".equals(skillname)) {
                jnxgz = (genggu * xishu[4] + lingxing * xishu[0] + liliang * xishu[3]) * zjxz / zuoqi[21][0] + shulian/ xishu[6] / zuoqi[21][1];
            } else if ("天神护体".equals(skillname)) {
                jnxgz = (genggu * 1 + lingxing * xishu[4] + liliang * xishu[4]) * zjxz / zuoqi[3][0] + shulian/ xishu[6] / zuoqi[3][1];
            } else if (skillname.equals("游刃有余")) {
                jnxgz = (genggu * 1 + lingxing * xishu[4] + liliang * xishu[4]) * zjxz / zuoqi[3][0] + shulian/ xishu[6] / zuoqi[3][1];
            }  else if (skillname.equals("山外青山")) {
                jnxgz = (genggu * 1 + lingxing * xishu[4] + liliang * xishu[4]) * zjxz / zuoqi[3][0] + shulian/ xishu[6] / zuoqi[3][1];
            }
        } else if ("连击率".equals(mes) || "致命".equals(mes) || "命中".equals(mes) ) {
            jnxgz = (genggu * xishu[5] + lingxing * xishu[3] + liliang * xishu[2]) * zjxz / zuoqi[22][0] + shulian  / 10000 / zuoqi[22][1];
        }  else if ("躲闪率".equals(mes)) {
            jnxgz = (genggu * xishu[5] + lingxing * xishu[3] + liliang * xishu[2]) * zjxz / zuoqi[22][0] + shulian  / 20000 / zuoqi[22][0];
        } else if (mes.equals("抗风法") || mes.equals("抗火法") || mes.equals("抗水法") || mes.equals("抗雷法")||mes.equals("抗鬼火")) {
            if ("天神护体".equals(skillname)) {
                jnxgz = (genggu * 1 + lingxing * xishu[4] + liliang * xishu[4]) * zjxz / zuoqi[2][0] + shulian / xishu[6] / zuoqi[2][1];
            } else if ("兴风作浪".equals(skillname)) {
                jnxgz = (genggu * xishu[1] + lingxing * xishu[2] + liliang * xishu[5]) * zjxz / zuoqi[12][0] + shulian / xishu[6] / zuoqi[12][1];
            } else if ("天雷怒火".equals(skillname)) {
                jnxgz = (genggu * xishu[4] + lingxing * xishu[2] + liliang * xishu[1]) * zjxz / zuoqi[15][0] + shulian  / xishu[6] / zuoqi[15][1];
            }
        } else if ("火法伤害".equals(mes) || "雷法伤害".equals(mes) || "火雷伤害".equals(mes)) {
            jnxgz = (genggu * xishu[5] + lingxing * xishu[3] + liliang * xishu[0]) * zjxz / zuoqi[14][0] + shulian  / 10000 / zuoqi[14][1];
        } else if ("抗火雷".equals(mes)) {
            jnxgz = (genggu * xishu[4] + lingxing * xishu[2] + liliang * xishu[1]) * zjxz / zuoqi[15][0] + shulian  / xishu[6] / zuoqi[15][1];
        } else if ("抗物理".equals(mes)) {
            jnxgz = (genggu * xishu[3] + lingxing * xishu[5] + liliang * xishu[0]) * zjxz / zuoqi[5][0] + shulian  / xishu[6] / zuoqi[5][1];
        } else if ("抗震慑".equals(mes)) {
            jnxgz = (genggu * xishu[3] + lingxing * xishu[4] + liliang * xishu[1]) * zjxz / zuoqi[6][0] + shulian  / xishu[6] / zuoqi[6][1];
        } else if ("抗中毒".equals(mes)) {
            if ("金身不坏".equals(skillname)) {
                jnxgz = (genggu * xishu[2] + lingxing * xishu[4] + liliang * xishu[0]) * zjxz / zuoqi[7][0] + shulian / 10000 / zuoqi[7][1];
            } else if ("心如止水".equals(skillname)) {
                jnxgz = (genggu * xishu[3] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian / xishu[7] / zuoqi[0][1];
            }
        } else if ("抗三尸虫".equals(mes)) {
            jnxgz = (genggu * xishu[2] + lingxing * xishu[4] + liliang * xishu[0]) * 125 / 3 + shulian * 1500 / 100000;
            ;
        } else if ("狂暴".equals(mes)) {
            if ("破釜沉舟".equals(skillname)) {
                jnxgz = (genggu * xishu[4] + lingxing * xishu[4] + liliang * 1) * zjxz / zuoqi[19][0] + shulian  / xishu[6] / zuoqi[19][1];
            } else if ("后发制人".equals(skillname)) {
                jnxgz = (genggu * xishu[1] + lingxing * xishu[5] + liliang * xishu[3]) * zjxz / zuoqi[17][0] + shulian  / xishu[6] / zuoqi[17][1];
            }
        } else if ("忽视防御几率".equals(mes) || "忽视防御程度".equals(mes)) {
            jnxgz = (genggu * xishu[4] + lingxing * xishu[5] + liliang * 1) * zjxz / zuoqi[20][0] + shulian / xishu[6]  / zuoqi[20][1];
        } else if ("风法伤害".equals(mes) || "水法伤害".equals(mes)) {
            jnxgz = (genggu * xishu[0] + lingxing * xishu[3] + liliang * xishu[5]) * zjxz / zuoqi[11][0] + shulian  / xishu[6] / zuoqi[11][1];
        } else if ("加强风".equals(mes) || "加强火".equals(mes) || "加强水".equals(mes) || "加强雷".equals(mes)) {
            jnxgz = (genggu * xishu[5] + lingxing * 1 + liliang * xishu[5]) * zjxz / zuoqi[9][0] + shulian / xishu[6]  / zuoqi[9][1];
        } else if (mes.equals("抗昏睡") || mes.equals("抗封印") || mes.equals("抗混乱") || mes.equals("抗遗忘")) {
            jnxgz = (genggu * xishu[3] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian  / xishu[7] / zuoqi[0][1];
        }  else if (mes.equals("反震率") || mes.equals("反震程度")) {
            jnxgz = (genggu * xishu[1] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[6][0];
        } else if (mes.equals("法术躲闪")) {
            jnxgz = (genggu * xishu[1] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[6][0];
        } else if (mes.equals("抵御强克效果")) {
            jnxgz = (genggu * xishu[1] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[0][1];
        } else if (mes.equals("抗灵宝伤害")) {
            jnxgz = (genggu * xishu[1] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[6][0];
        } else if (mes.equals("增加强克效果")) {
            jnxgz = (genggu * xishu[1] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[0][1];
        } else if (mes.equals("忽视抗水")) {
            jnxgz = (genggu * xishu[3] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[0][1];
        } else if (mes.equals("忽视抗雷")) {
            jnxgz = (genggu * xishu[3] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[0][1];
        } else if (mes.equals("忽视抗风")) {
            jnxgz = (genggu * xishu[3] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[0][1];
        } else if (mes.equals("忽视抗火")) {
            jnxgz = (genggu * xishu[3] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[0][1];
        }  else if (mes.equals("忽视鬼火")) {
            jnxgz = (genggu * xishu[3] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[0][1];
        } else if (mes.equals("鬼火狂暴")) {
            jnxgz = (genggu * xishu[3] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[0][1];
        }else if (mes.equals("水法狂暴")) {
            jnxgz = (genggu * xishu[3] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[0][1];
        }else if (mes.equals("雷法狂暴")) {
            jnxgz = (genggu * xishu[3] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[0][1];
        }else if (mes.equals("风法狂暴")) {
            jnxgz = (genggu * xishu[3] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[0][1];
        }else if (mes.equals("火法狂暴")) {
            jnxgz = (genggu * xishu[3] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[0][1];
        }else if (mes.equals("反击率")) {
            jnxgz = (genggu * xishu[3] + lingxing * xishu[0] + liliang * xishu[4]) * zjxz / zuoqi[0][0] + shulian/ xishu[7] / zuoqi[0][1];
        }
        String ss = mes + "=" + keepTwoDecimals(jnxgz / 100);
        if ("抗三尸虫".equals(mes)) {
            ss = mes + "=" + (int) keepTwoDecimals(jnxgz);
        }
        return ss;

    }

    /**
     * 保留两位小数的方法
     */
    public static double keepTwoDecimals(Double value) {
        BigDecimal b = new BigDecimal(value);
        double d = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
        return d;
    }

    private static Object object = new Object();

    /**
     * 获取时间参数
     */
    public static long getTime() {
        return BJTime;
    }

    /**
     * 根据时间参数做唯一标识
     */
    static int s = 0;

    public static long getTime2() {
        synchronized (object) {
            s++;
            BJTime++;
            return BJTime;
        }
    }

    /**
     * 记录时间流逝
     */
    public static void addtime(int sj) {
        synchronized (object) {
            sj = sj - s;
            s = 0;
            BJTime += sj;
        }
    }

    static long time;

    /**
     * 点击间隔
     */
    public static boolean isM() {
        if (BJTime - time < 200) {
            return true;
        }
        time = BJTime;
        return false;
    }

    /**
     * 判断是否解锁背包
     */
    public static boolean isCanBuyOrno() {
        if (!canBuyOrno) {
            if (RoleData.getRoleData().getLoginResult().getPassword() == null) {
                FormsManagement.showForm(32);
            } else {
                FormsManagement.showForm(33);
            }
            return true;
        }
        return false;
    }


    //	子时——晚11点钟到凌晨1点钟；
    //	丑时——1点钟至3点钟；
    //	寅时——3点钟至5点钟；
    //	卯辰——5点钟至7点钟；
    //	辰时——7点钟至9点钟；
    //	巳时——9点钟至11点钟；
    //	午时——11点钟至下午1点钟；
    //	未时——13点钟至15点钟；
    //	申时——下午3点钟至5点钟；
    //	酉时——下午5点钟至7点钟；
    //	戌时——下午7点钟至晚9点钟；
    //	亥时——晚9点钟至11点钟。
    public static String getHour(int hour) {
        String SC = "";
        if (hour == 23 || hour == 0) {
            SC = "子时";
        }
        if (hour == 1 || hour == 2) {
            SC = "丑时";
        }
        if (hour == 3 || hour == 4) {
            SC = "寅时";
        }
        if (hour == 5 || hour == 6) {
            SC = "卯辰";
        }
        if (hour == 7 || hour == 8) {
            SC = "辰时";
        }
        if (hour == 9 || hour == 10) {
            SC = "巳时";
        }
        if (hour == 11 || hour == 12) {
            SC = "午时";
        }
        if (hour == 13 || hour == 14) {
            SC = "未时";
        }
        if (hour == 15 || hour == 16) {
            SC = "申时";
        }
        if (hour == 17 || hour == 18) {
            SC = "酉时";
        }
        if (hour == 19 || hour == 20) {
            SC = "戌时";
        }
        if (hour == 21 || hour == 22) {
            SC = "亥时";
        }
        return SC;
    }

    //泡点
    public static String formatTime(Long ms) {
        if (!qbg) {
            return "";
        }
        Integer ss = 1000;
        Integer mi = ss * 60;
        Integer hh = mi * 60;
        Integer dd = hh * 24;

        Long day = ms / dd;
        Long hour = (ms - day * dd) / hh;
        Long minute = (ms - day * dd - hour * hh) / mi;
        Long second = (ms - day * dd - hour * hh - minute * mi) / ss;
        if (second != 0 && !jz.equals(second)) {
            if (second % tm == 0) {
                if ("2".equals(pdtype)) {
                    //扣钱 金币
                    if (UserData.uptael(hf)) {
                        LoginResult loginResult = RoleData.getRoleData().getLoginResult();
                        Long exp = 0L;
                        if (loginResult.getTurnAround() == 0) {
                            exp = jy;
                        } else if (loginResult.getTurnAround() == 1) {
                            exp = jy;
                        } else if (loginResult.getTurnAround() == 2) {
                            exp = jy * 2;
                        } else if (loginResult.getTurnAround() == 3) {
                            exp = jy * 3;
                        } else if (loginResult.getTurnAround() == 4) {
                            exp = jy * 4;
                        }
                        SendMessageUntil.toServer(Agreement.getAgreement().expaddAgreement("expAddJ=" + exp));
                        hdzjy = hdzjy + exp;
                        xfzje = xfzje + hf;
                        jz = second;
                    } else {//不够送回长安
                        ZhuFrame.getZhuJpanel().addPrompt2("#R注意：#Y金钱不足，退出泡点地图！努力赚钱，下次再来！");
                        iWantToFly("1207,长安城,4960,3820");
                        qbg = false;
                    }
                } else if ("3".equals(pdtype)) {
                    //判断 仙玉 是否够
                    Long xy = hf / 10000;
                    if (isxy(xy)) {
                        LoginResult loginResult = RoleData.getRoleData().getLoginResult();
                        Long exp = 0L;
                        if (loginResult.getTurnAround() == 0) {
                            exp = jy * 2;
                        } else if (loginResult.getTurnAround() == 1) {
                            exp = jy * 2;
                        } else if (loginResult.getTurnAround() == 2) {
                            exp = jy * 3;
                        } else if (loginResult.getTurnAround() == 3) {
                            exp = jy * 4;
                        } else if (loginResult.getTurnAround() == 4) {
                            exp = jy * 5;
                        }
                        SendMessageUntil.toServer(Agreement.getAgreement().expaddAgreement("expAddY=" + exp + "=" + xy));
                        hdzjy = hdzjy + exp;
                        xfzxy = xfzxy + xy;
                        jz = second;
                    } else {//不够送回长安
                        ZhuFrame.getZhuJpanel().addPrompt2("#R注意：#Y仙玉不足，退出泡点地图！努力赚钱，下次再来！");
                        iWantToFly("1207,长安城,4960,3820");
                        qbg = false;
                    }
                } else if ("1".equals(pdtype)) {
                    LoginResult loginResult = RoleData.getRoleData().getLoginResult();
                    Long exp = 0L;
                    if (loginResult.getTurnAround() == 0) {
                        exp = jy / 10;
                    } else if (loginResult.getTurnAround() == 1) {
                        exp = jy / 10;
                    } else if (loginResult.getTurnAround() == 2) {
                        exp = jy * 2 / 10;
                    } else if (loginResult.getTurnAround() == 3) {
                        exp = jy * 3 / 10;
                    } else if (loginResult.getTurnAround() == 4) {
                        exp = jy * 4 / 10;
                    }
                    exp = exp * victory;
                    SendMessageUntil.toServer(Agreement.getAgreement().expaddAgreement("expAddM=" + exp + "=" + victory));
                    hdzjy = hdzjy + exp;
                    jz = second;
//        	    		ZhuFrame.getZhuJpanel().addPrompt2("#R注意：#Y战斗失败，退出泡点地图！努力变强，下次再来！");
//        	    		iWantToFly("1207,长安城,4070,2710");
//        	    		qbg = false;
                }
            }
        }
//        Long milliSecond = ms - day * dd - hour * hh - minute * mi - second * ss;
        StringBuffer sb = new StringBuffer();
        if (day > 0) {
            sb.append(day + "天");
        }
        if (hour > 0) {
            sb.append(hour + "小时");
        }
        if (minute > 0) {
            sb.append(minute + "分");
        }
        if (second > 0) {
            sb.append(second + "秒");
        }
//        if(milliSecond > 0) {
//            sb.append(milliSecond+"毫秒");
//        }
        return sb.toString();
    }


    //泡点
    //传送 坐标 例如 ：1207,长安城,4070,2710
    public static void iWantToFly(String npcfeiji) {
        if (npcfeiji == null || npcfeiji.length() == 0) {
            ZhuFrame.getZhuJpanel().addPrompt2("坐标为空，无法传送");
        } else {
            String kkf = "传送=" + npcfeiji + ", 可用次数=10";
            String kkf0 = "传送=" + npcfeiji;
            String kkf1 = npcfeiji;
            String[] vs = kkf.split(",");
            String[] cishu = vs[vs.length - 1].split("=");
            int sum = Integer.parseInt(cishu[1]);
            --sum;
            String[] path = null;
            StringBuffer buffer = new StringBuffer();
            if (buffer.length() != 0) {
                buffer.append("|");
            }
            buffer.append(kkf0);
            if (path == null) {
                String[] pathv = kkf1.split(",");
                String wz = pathv[1] + "(" + pathv[2] + "," + pathv[3] + ")";
                path = pathv;
            }
            if (buffer.length() != 0) {
                buffer.append("|");
            }
            buffer.append(cishu[0]);
            buffer.append("=");
            buffer.append(sum);
            if (path != null) {
                if (sum <= 0) {
                    NPCJfram.getNpcJfram().getNpcjpanel().getGood().setUsetime(0);
                }
                GoodsMouslisten.gooduse(NPCJfram.getNpcJfram().getNpcjpanel().getGood(), 2);
                if (sum <= 0) {
                    GoodsListFromServerUntil.Deletebiaoid(NPCJfram.getNpcJfram().getNpcjpanel().getGood().getRgid());
                }
                Door door = new Door();
                door.setDoormap(path[0]);
                door.setDoorpoint(path[2] + "|" + path[3]);

                try {
                    TP.tp(door, 1);
                } catch (Exception var9) {
                    var9.printStackTrace();
                }
            }
        }
        FormsManagement.HideForm(1102);
    }

    //判断金币
    public static boolean isjb(Long tael) {
        long shengyu = RoleData.getRoleData().getLoginResult().getGold().longValue() - tael;
        if (tael > 0 && shengyu >= 0) {
            return true;
        } else {
            return false;
        }
    }

    //仙玉
    public static boolean isxy(Long tael) {
        if (tael > RoleData.getRoleData().getLoginResult().getCodecard().longValue()) {
            return false;
        } else {
            return true;
        }
    }

    public static String number2Chinese(final int value) {
        String result = "";
        int i = String.valueOf(value).length() - 1;
        while (i >= 0) {
            final int r = (int) ((double) value / Math.pow(10.0, (double) i));
            result = result + Util.NUMS[r % 10] + Util.UNITS[i];
            --i;
        }
        result = result.replaceAll("零[十, 百, 千]", "零");
        result = result.replaceAll("零+", "零");
        result = result.replaceAll("零([万, 亿])", "$1");
        result = result.replaceAll("亿万", "亿");
        if (result.startsWith("一十")) {
            result = result.substring(1);
        }
        if (result.endsWith("零")) {
            result = result.substring(0, result.length() - 1);
        }
        return result;
    }

    public static String readHotkey(String roleId) {
        String value = readTxt("resource/other/hotKey_" + roleId + ".txt");
        if (value == null || "".equals(value)) {
            return null;
        }
        String value2 = NewAESUtil.AESJDKDncode(value);
        if (value2 == null) {
            if (value.indexOf("=") != -1) {
                writeUserPwd(value);
                return value;
            }
            return "";
        }
        value2 = value2.substring(13);
        if (GameClient.Mac == null) {
            try {
                GameClient.getServerIpAndPort();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        if (value2.startsWith(GameClient.Mac)) {
            return value2.substring(17);
        }
        return "";
    }

    /**
     * 记录用户快捷键
     */
    public static void writeHotkey(String roleId, String text) {
        try {
            //system.out.println(GameClient.Mac);
            String filein = GameClient.Mac + text;
            try (OutputStreamWriter write = new OutputStreamWriter(new FileOutputStream(new File(
                    "resource/other/hotKey_" + roleId + ".txt")), "UTF-8");
                 BufferedWriter writer = new BufferedWriter(write)) {
                writer.write(NewAESUtil.AESJDKEncode(filein));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static petExchange getPetfoid(String summoningname) {
        petExchange pet = new petExchange();
        allPetExchange petall = UserMessUntil.getAllPetExchange();
        List<petExchange> petTujianList = new ArrayList<>();
        ConcurrentHashMap<Integer, petExchange> map = petall.getAllPetExchange();
        for(Map.Entry<Integer, petExchange> entry:map.entrySet()){
            petTujianList.add(entry.getValue());
        }
        for(petExchange summoning:petTujianList) {
            if(summoning.getName().equals(summoningname)) {
                pet = summoning;
                break;
            }
        }
        return pet;
    }

    public static void writeAutoNum(String roleId,String text) {
        try {
            System.out.println(GameClient.Mac);
            String filein = GameClient.Mac + text;
            try (OutputStreamWriter write = new OutputStreamWriter(Files.newOutputStream(new File("resource/other/autoNum_" + roleId + ".txt").toPath()), StandardCharsets.UTF_8);
                 BufferedWriter writer = new BufferedWriter(write)) {
                writer.write(Objects.requireNonNull(NewAESUtil.AESJDKEncode(filein)));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static String readAutoNum(String roleId) {
        String value = readTxt("resource/other/autoNum_"+roleId+".txt");
        if(value==null||"".equals(value)){
            return null;
        }
        String value2 = NewAESUtil.AESJDKDncode(value);
        value2 = value2.substring(13);
        if(GameClient.Mac==null) {
            try {
                GameClient.getServerIpAndPort();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        if (value2.startsWith(GameClient.Mac)) {
            return value2.substring(17);
        }
        return "";
    }

    public static String setZhiWeiRank(int value) {
        String rank = "";
        if (value >= 5000) {
            rank = "五方揭谛";
        } else if (value >= 3000) {
            rank = "六丁六甲";
        } else if (value >= 1000) {
            rank = "护法珈蓝";
        } else if (value >= 500) {
            rank = "三十六天将";
        } else if (value >= 100) {
            rank = "日值功曹";
        } else if (value >= 0) {
            rank = "城隍土地";
        }
        return rank;
    }

}
